package edu.base.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import edu.base.util.HigherResponse;
import edu.base.entity.RecordRepair;
import edu.base.service.RecRepService;

/**
 * @author 10173
 *
 */
@Controller		
@RequestMapping("/record")
public class RecRepCon {
	
	@Autowired
	private RecRepService recRepService;
	
	//查询所有报修记录
	@ResponseBody
	@RequestMapping("/list.do")
	public HigherResponse<PageInfo<RecordRepair>> queryRecByPage(@RequestParam(required=true,defaultValue="1")Integer pageNum,@RequestParam(required=true,defaultValue="6")Integer pageSize){
		return recRepService.queryRecByPage(pageNum, pageSize);
	}

	
	//根据日期、预约方式和报修状态查询报修记录
	@ResponseBody
	@RequestMapping("/queryRecByDate.do")
	public HigherResponse<PageInfo<RecordRepair>> queryRecByDate(String beginDate, String endDate,Integer repairStatus,Integer appointment, @RequestParam(required=true,defaultValue="1")Integer pageNum, @RequestParam(required=true,defaultValue="2")Integer pageSize){
		return recRepService.queryRecByDate(beginDate,endDate,repairStatus,appointment,pageNum, pageSize);
	}
	
	//根据报修id查询报修记录
	@ResponseBody
	@RequestMapping("/queryOneRec.do")
	public HigherResponse<RecordRepair> queryOneRec(Integer id){
		return recRepService.queryOneRec(id);
	}
	
	//更新报修记录信息
	@ResponseBody
	@PostMapping("/updateRec.do")
	public HigherResponse<String> updateRecById(RecordRepair recRep){
		return recRepService.updateRecById(recRep);
	}
	
	//添加报修记录
	@ResponseBody
	@PostMapping("/insertRec.do")
	public HigherResponse<String> insertRec(RecordRepair recRep) {
		return recRepService.insertRec(recRep);
	}
	
	//删除报修记录for real
	@ResponseBody
	@RequestMapping("/deleteRec.do")
	public HigherResponse<String> deleteRecRepById(Integer id) {
		return recRepService.deleteRecRepById(id);
	}
	
	//删除报修记录fake
	@ResponseBody
	@RequestMapping("/updateStatus.do")
	public HigherResponse<String> updateStatus(Integer id) {
		return recRepService.updateStatus(id);
	}
	
	//批量删除数据
	@ResponseBody
	@RequestMapping("/updateRecStatus.do")
	public HigherResponse<String> updateRecStatus(List<Integer> ids) {
		return recRepService.updateRecStatus(ids);
	}
}
